package cn.juque.datapipeline.api.enums;

import cn.juque.common.exception.AppException;

/**
 * @author nuoka
 * @version 1.0.0
 * <li></li>
 * @date 2022/7/20 19:59
 **/
public enum DbEnum {

    /**
     * enum
     */
    MYSQL(1, "mysql"),
    ORACLE(2, "oracle"),
    ;
    private final Integer code;

    private final String label;

    DbEnum(Integer code, String label) {
        this.code = code;
        this.label = label;
    }

    public static DbEnum forEnum(Integer code) {
        for (DbEnum dbEnum : DbEnum.values()) {
            if (dbEnum.getCode().equals(code)) {
                return dbEnum;
            }
        }
        throw new AppException(DataPipelineMsgEnum.DB_TYPE_MISSING);
    }

    public Integer getCode() {
        return code;
    }
}
